<template>
  <div class="my-transactions">
    <h3 class="section-title">我的交易</h3>
    <el-row class="transactions-grid" justify="space-around">
      <el-col :span="6" class="transaction-item" @click="goToPosted">
        <div class="icon-wrap">
          <el-icon class="transaction-icon"><Goods /></el-icon>
        </div>
        <div class="label">我发布的</div>
      </el-col>
      <el-col :span="6" class="transaction-item" @click="goToSold">
        <div class="icon-wrap">
          <el-icon class="transaction-icon"><Money /></el-icon>
        </div>
        <div class="label">我卖出的</div>
      </el-col>
      <el-col :span="6" class="transaction-item" @click="goToBought">
        <div class="icon-wrap">
          <el-icon class="transaction-icon"><Check /></el-icon>
        </div>
        <div class="label">我买到的 <span class="count">{{ boughtCount }}</span></div>
      </el-col>
      <el-col :span="6" class="transaction-item" @click="goToEvaluate">
        <div class="icon-wrap">
          <el-icon class="transaction-icon"><Comment /></el-icon>
        </div>
        <div class="label">待评价</div>
      </el-col>
    </el-row>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import { useRouter } from 'vue-router';
import { Goods, Money, Check, Comment } from '@element-plus/icons-vue';

const router = useRouter();

// 动态数据
const boughtCount = ref(1); // 示例数据，后续从接口获取

// 跳转方法（后续实现具体页面）
const goToPosted = () => router.push('/personal/myposted');
const goToSold = () => router.push('/personal/mysold');
const goToBought = () => router.push('/personal/mybought');
const goToEvaluate = () => router.push('/my-evaluate');
</script>

<style scoped>
.my-transactions {
  padding: 20px;
  background: #f8f8f8;
  border-radius: 12px;
  margin-top: 20px;
}

.section-title {
  font-size: 18px;
  font-weight: 500;
  color: #333;
  margin-bottom: 15px;
}

.transactions-grid {
  background: #fff;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.transaction-item {
  text-align: center;
  cursor: pointer;
  transition: transform 0.3s;
}

.transaction-item:hover {
  transform: scale(1.05);
}

.icon-wrap {
  width: 40px;
  height: 40px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #f5f5f5;
}

.transaction-icon {
  font-size: 24px;
  color: #666;
}

.label {
  font-size: 14px;
  color: #666;
}

.count {
  font-weight: 500;
  color: #b50241;
}
</style>